<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="layui/css/layui.css"  media="all">
<link rel="stylesheet" href="layui/css/layui.mobile.css"/>
<script src="js/jquery3.3.1.min.js"></script>
<script src="layui/layui.all.js"></script>
<script src="layui/layui.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $(".click").click(function(){
  $(".tip").fadeIn(200);
  });
	
  
  $(".tiptop a").click(function(){
  $(".tip").fadeOut(200);
});

  $(".sure").click(function(){
  $(".tip").fadeOut(100);
});

  $(".cancel").click(function(){
  $(".tip").fadeOut(100);
});
	
$(".all").click(function () {
                if(this.checked){
                    $(".list :checkbox").attr("checked", true);
                }else{
                    $(".list :checkbox").attr("checked", false);
                }
            });
});

function selectAll(){
    if ($("#SelectAll").is(":checked")) {
        $(":checkbox").prop("checked", true);//所有选择框都选中
    } else {
        $(":checkbox").prop("checked", false);
    }
}
function roomDeletes(){
    //判断至少写了一项
    var checkedNum = $("input[name='subcheck']:checked").length;
    if(checkedNum==0){
        alert("请至少选择一项!");
        return false;
    }
    var result="";
    var count=0;
    $(".checkb").each(function(){
        if($(this).is(':checked')){
            result+=$(this).val()+",";
            count++;
        }else{}
    });
    if(!confirm("确定删除这"+count+"个游戏?")){
        return;
    }
    window.location.href= "/roomDeletes?tag="+result;}
	
	function changeRoomStatus(){
            //异步查询出数据,当ajax请求的网址响应返回后，会自动回调匿名函数
        var checkedNum = $("input[name='subcheck']:checked").length;
        if(checkedNum==0){
            alert("请至少选择一项!");
            return false;
        }
        var result="";
        var count=0;
        $(".checkb").each(function(){
            if($(this).is(':checked')){
                result+=$(this).val()+",";
                count++;
            }else{}
        });
        if(!confirm("确定通过这"+count+"个房间?")){
            return;
        }
        window.location.href= "/roomCheck?tag="+result;

	}

function editroom(roomid){
    //异步查询出数据,当ajax请求的网址响应返回后，会自动回调匿名函数
    $.post("/checkroom",{"roomid":roomid},function(data){
        $("#roomid").val("");
        $("#roomname").val("");
        $("#roomid").val(data.roomid);
        $("#roomname").val(data.roomname);
    })
    //负责显示窗口
    var	layer = layui.layer;
    var othis = $(this);
    var type = othis.data('type')
    var text = othis.text();
    layer.open({
        type: 1
        ,skin:'layui-layer-molv'
        ,offset:type
        ,id: 'layerDemo'+type //防止重复弹出
        ,content: $(".form4")
        ,btnAlign: 'c' //按钮居中
        ,shade: 0.5 //不显示遮罩
        ,title:"审核房间"
        ,area:['700px','500px']
        ,yes: function(index, layero){
            layer.close(index);
        },
        btn2: function(index, layero){
            $(".form3").submit();
        },
        end:function(){
            $(".form4").hide();
        }
    });
}
</script>


</head>


<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">游戏管理</a></li>
    </ul>
    </div>

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  <ul class="layui-tab-title">
       <li class="layui-this">游戏房间管理</li>
  </ul>
  <div class="layui-tab-content">
   <!--游戏管理-->
    <div class="layui-tab-item layui-show">
     <div class="rightinfo">
    <div class="tools">
    	<ul class="toolbar">
        <li onclick="changeRoomStatus()"><span><img src="images/t01.png" /></span>通过</li>
        <li onclick="roomDeletes()"><span><img src="images/t03.png" /></span>删除</li>
        </ul>
    </div>
    <table class="tablelist">
    	<thead>
    	<tr>
        <th><input onclick="selectAll()" id="SelectAll"  type="checkbox" value=""/></th>
        <th>房间ID</th>
        <th>房间名称</th>
        <th>游戏名称</th>
        <th>游戏类型</th>
        <th>房间状态</th>
        <th>审核状态</th>
        <th>操作</th>
        </tr>
        </thead>

        <tbody  class="list">
        <c:forEach items="${roomPageInfo.list}" var="temp">
        <tr>
        <td><input class="checkb" id="subcheck" name="subcheck" type="checkbox" value="${temp.roomid}" /></td>
        <td>${temp.roomid}</td>
        <td>${temp.roomname}</td>
        <td>${temp.game.gamename}</td>
        <td>${temp.gameType.typename}</td>
        <c:choose>
            <C:when test="${temp.isfull==1}">
                 <td>未满</td>
            </C:when>
            <c:otherwise><td>满员</td></c:otherwise>
        </c:choose>
        <c:choose>
            <c:when test="${temp.roomstatus==2}"><td>违规操作（禁用）</td></c:when>
            <c:when test="${temp.roomstatus==3}"><td>待审核</td></c:when>
            <c:otherwise><td>通过</td></c:otherwise>
        </c:choose>
            <td><a onclick="editroom(${temp.roomid})" class="tablelink" name="roomid" href="#">审核</a>     <a href="/delRoom?roomid=${temp.roomid}" class="tablelink"> 删除</a></td>
        </tr>
        </c:forEach>
        </tbody>

    </table>
    <div class="pagin">
    	<div class="message">共<i class="blue">${roomPageInfo.total}</i>条记录，当前显示第&nbsp;<i class="blue">${roomPageInfo.pageNum}&nbsp;</i>页</div>
        <ul class="paginList">
            <li class="paginItem current"><a href="room?roomPageNum=1">首页</a></li>
            <c:choose>
            <c:when test="${roomPageInfo.isFirstPage}">
                <li class="paginItem"><a href="room?roomPageNum=1"><span class="pagepre"></span></a></li>
            </c:when>
            <c:otherwise>
                <li class="paginItem"><a href="room?roomPageNum=${roomPageInfo.prePage}"><span class="pagepre"></span></a></li>
            </c:otherwise>
        </c:choose>
        <li class="paginItem current"><a href="javascript:;">${roomPageInfo.pageNum}</a></li>
        <c:choose>
            <c:when test="${roomPageInfo.isLastPage}">
                <li class="paginItem"><a href="room?roomPageNum=${roomPageInfo.pages}"><span class="pagenxt"></span></a></li>
            </c:when>
            <c:otherwise>
                <li class="paginItem"><a href="room?roomPageNum=${roomPageInfo.nextPage}"><span class="pagenxt"></span></a></li>
            </c:otherwise>
        </c:choose>
            <li class="paginItem current"><a href="room?roomPageNum=${roomPageInfo.pages}">尾页</a></li>

        </ul>
    </div>
    </div>
        <%--添加game弹窗--%>
     <div class="form2" style="padding:20px 20px;display: none;">
        <form class="layui-form form1" action="/addRoom" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">房间名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="gamename" required lay-verify="required" placeholder="请输入游戏名称" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">游戏类型</label>
                <div class="layui-input-block">

                    <select name="typeid" lay-verify="required">
                        <c:forEach items="${typelist}" var="temp1">
                        <option value="${temp1.typeid}">${temp1.typename}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">下载路径</label>
                <div class="layui-input-inline">
                    <input type="text" name="downloadfile" id="downloadfile" required lay-verify="required" placeholder="请输入下载路径" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="1" title="启用">
                    <input type="radio" name="status" value="2" title="禁用" checked>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn"  lay-filter="formDemo" style="background-color:#4098CA" >立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
        <%--修改gameroom弹窗--%>
     <div class="form4" style="padding:20px 20px;display: none;">
         <form class="layui-form form3" action="editRoom">
             <div class="layui-form-item">
                 <label class="layui-form-label">房间ID</label>
                    <div class="layui-input-block">
                        <input readonly  unselectable="on"  style="width:40px;" type="text" name="roomid" id="roomid" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
             </div>
             <div class="layui-form-item">
                 <label class="layui-form-label">房间名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="roomname" id="roomname" required lay-verify="required" placeholder="请输入房间名称" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
             </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="roomstatus" value="3" title="待审核">
                        <input type="radio" name="roomstatus" value="1" title="启用">
                        <input type="radio" name="roomstatus" value="2" title="禁用" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-filter="formDemo" style="background-color:#4098CA" >立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>

        <script>
            //Demo
            layui.use('form', function(){
                var form = layui.form;

                //监听提交
                form.on('submit(formDemo)', function(data){
                    layer.msg(JSON.stringify(data.field));
                    return false;
                });
            });
        </script>
    </div>

  </div>
</div>

  


</body>

</html>
